
IF(WIN32)
  ADD_DEFINITIONS(-DGEEX_EXPORTS)
  ADD_DEFINITIONS(-DGL2PSDLL)
  ADD_DEFINITIONS(-DGL2PSDLL_EXPORTS)
  ADD_DEFINITIONS(-DDLL_EXPORTS)
ELSE(WIN32)
  ADD_DEFINITIONS(-DBINARY_DIR=\\"${CMAKE_BINARY_DIR}\\")
  ADD_DEFINITIONS(-DPROJECT_ROOT=\\"${CMAKE_SOURCE_DIR}\\")
ENDIF(WIN32)

IF (WIN32)
   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/glut-win32/include)
   LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/glut-win32/lib)
ELSE (WIN32)
   LINK_DIRECTORIES(/usr/X11R6/lib)
ENDIF (WIN32)

AUX_SOURCE_DIRECTORY(basics SOURCES)
AUX_SOURCE_DIRECTORY(mathematics SOURCES)
AUX_SOURCE_DIRECTORY(numerics SOURCES)
AUX_SOURCE_DIRECTORY(symbolics SOURCES)
AUX_SOURCE_DIRECTORY(properties SOURCES)
AUX_SOURCE_DIRECTORY(combinatorics SOURCES)
AUX_SOURCE_DIRECTORY(graphics SOURCES)
AUX_SOURCE_DIRECTORY(CVT SOURCES)

AUX_SOURCE_DIRECTORY(third_party/zlib SOURCES)
AUX_SOURCE_DIRECTORY(third_party/gzstream SOURCES)
AUX_SOURCE_DIRECTORY(third_party/png SOURCES)
AUX_SOURCE_DIRECTORY(third_party/GLsdk SOURCES)
AUX_SOURCE_DIRECTORY(third_party/pbuffer SOURCES)
AUX_SOURCE_DIRECTORY(third_party/glut_viewer SOURCES)
AUX_SOURCE_DIRECTORY(third_party/glu SOURCES)
AUX_SOURCE_DIRECTORY(third_party/misc SOURCES)
AUX_SOURCE_DIRECTORY(third_party/LBFGSB SOURCES)
AUX_SOURCE_DIRECTORY(third_party/HLBFGS SOURCES)
AUX_SOURCE_DIRECTORY(third_party/METIS SOURCES)
INCLUDE_DIRECTORIES(third_party/tsANN/include)
AUX_SOURCE_DIRECTORY(third_party/tsANN/src SOURCES)
AUX_SOURCE_DIRECTORY(third_party/tetgen SOURCES)
AUX_SOURCE_DIRECTORY(third_party/AntTweakBar SOURCES)
INCLUDE_DIRECTORIES(third_party/AntTweakBar/include)
AUX_SOURCE_DIRECTORY(third_party/LMBM SOURCES)

AUX_SOURCE_DIRECTORY(third_party/f2c/src/libF77 SOURCES)
AUX_SOURCE_DIRECTORY(third_party/f2c/src/libI77 SOURCES)
INCLUDE_DIRECTORIES(third_party/f2c/include)

ADD_LIBRARY(geex ${SOURCES})

IF (WIN32)
ADD_DEFINITIONS(-DD3D10_IGNORE_SDK_LAYERS) 
ENDIF (WIN32)

SET(LINUX 1)

IF (CMAKE_CL_64)
SET(WIN32 0)
SET(WIN64 1)
ENDIF (CMAKE_CL_64)

IF (WIN32)
   TARGET_LINK_LIBRARIES(geex glut32 opengl32 glu32)
   SET_TARGET_PROPERTIES(geex PROPERTIES LINK_FLAGS "/INCREMENTAL")
   SET(LINUX 0)
ENDIF (WIN32)

IF (WIN64)
   TARGET_LINK_LIBRARIES(geex glut64 opengl32 glu32)
   SET_TARGET_PROPERTIES(geex PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB:msvcrt /INCREMENTAL" LINK_FLAGS_RELEASE "/INCREMENTAL")
   SET(LINUX 0)   
ENDIF (WIN64)

IF (LINUX)
     TARGET_LINK_LIBRARIES(geex glut GL GLU X11 Xext Xi)
ENDIF (LINUX)

IF (CMAKE_CL_64)
SET(WIN32 1)
SET(WIN64 0)
ENDIF (CMAKE_CL_64)

IF (WITH_GINAC)
   TARGET_LINK_LIBRARIES(geex ginac)
ENDIF (WITH_GINAC)
